<template>
  <el-card class="main-left">
    <template #header>
      <div class="card-header">
        <span>{{ title }}</span>
        <el-button class="button" @click="handleGetMore" >更多</el-button>
      </div>
    </template>
    <div class="content">
      <ul>
        <li v-for="news in newsList">
          <nuxt-link :to="`news/${news.id}`" target="_blank" class="link">
            <div class="news-item-template">
                <img :src="news?.thumbnail" alt="news-pic"/>
                <NuxtLink :to="`/home/news-${news.id}`" style="text-decoration: none; margin: 0; padding: 0;" target="_blank">
                  <span>{{news.title}}</span>
                </NuxtLink>
            </div>
          </nuxt-link>
        </li>
      </ul>
    </div>
  </el-card>
</template>

<script setup lang="ts">
const props = defineProps<{
  title:string,
  catKey:string,
}>();

const handleGetMore = ()=>{
  window.open(`/cat/${props.catKey}`);
}


const newsList = ref([
  {
    title: "这是一个测试新闻链接",
    thumbnail: "/1.png",
  },{
    title: "这是一个测试新闻链接",
    thumbnail: "/1.png",
  },{
    title: "这是一个测试新闻链接",
    thumbnail: "/1.png",
  },{
    title: "这是一个测试新闻链接",
    thumbnail: "/1.png",
  },{
    title: "这是一个测试新闻链接",
    thumbnail: "/1.png",
  }
])
</script>

<style scoped>
.el-card{
  height: 280px;
  overflow: hidden;
  margin-bottom: 12px;
}
.card-header{
  padding: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--main-background);
  color: white;
}

.link{
  color: white;
  text-decoration: none;
}

.content{
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  background: var(--main-background);
  color: white;
  height: 275px;
}

.content ul{
  margin: 5px;
  padding: 0;
}

.content ul li{
  height: 40px;
  padding: 2px;
}

.button{
  background: var(--second-background);
  border: 0;
  color: white;
}

.news-item-template {
  height: 36px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.news-item-template img{
  width: 36px;
  height: 36px;
}

.news-item-template span{
  color: orange;
  margin-left: 5px;
}

</style>

<style>
.el-card__header{
  margin: 0 !important;
  padding: 0 !important;
}

.el-card__body{
  margin: 0;
  padding: 0;
}
</style>